package cl.whyem.utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.faces.model.SelectItem;

public class TutorialesUtil {
	
	public static final String GOOGLE = "google";
	public static final String YAHOO = "yahoo";
	public static final String BING = "bing";

	public static List<SelectItem> getSearchEnginesList() {
		String [] searchEngines = {GOOGLE,YAHOO,BING};
		List<SelectItem> list = new ArrayList<SelectItem>();
		for(int i=0 ; i < searchEngines.length; i++) {
			SelectItem sItem = new SelectItem();
			sItem.setValue(i);
			sItem.setDescription(searchEngines[i]);
			list.add(sItem);
		}
		return list;
	}
	
	public static List<String> getSearchEnginesStringList() {
		String [] searchEngines = {"google","yahoo","bing"};
		return Arrays.asList(searchEngines);
	}
	
	public static String makeURL(String engine, String param) {
		String urlRedirection = "";
		if(engine.equals(GOOGLE)) {
			urlRedirection = "http://www.google.com/search?&q="+param;
		}else if(engine.equals(YAHOO)) {
			urlRedirection = "http://cl.search.yahoo.com/search?p="+param;
		}else if(engine.equals(BING)) {
			urlRedirection = "http://www.bing.com/search?q="+param;
		}
		return urlRedirection;
	}
}
